package com.yeyks.commonReference.utils;

import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.yeyks.hotel.dal.domain.HotelInfo;
import com.yeyks.hotel.dal.domain.RoomInfo;
import com.yeyks.order.dal.domain.OrderBill;
import com.yeyks.search.pojo.model.EsHotelInfo;
import com.yeyks.search.pojo.model.EsRoomInfo;

public class ExtInfoToBeanUtil {

    //OrderBill HotelExtraInfo
    public static HotelInfo obtainHotelInfo(OrderBill orderBill) {
        if (StrUtil.isNotBlank(orderBill.getHotelExtraInfo())) {
            EsHotelInfo hotelInfo = JSONUtil.toBean(orderBill.getHotelExtraInfo(), EsHotelInfo.class);
            return hotelInfo;
        }
        return null;
    }

    //OrderBill RoomExtraInfo
    public static RoomInfo obtainRoomInfo(OrderBill orderBill) {
        if (StrUtil.isNotBlank(orderBill.getRoomExtraInfo())) {
            EsRoomInfo roomInfo = JSONUtil.toBean(orderBill.getRoomExtraInfo(), EsRoomInfo.class);
            ConfidentialOperationUtil.dealRoomInfo(roomInfo);
            return roomInfo;
        }
        return null;
    }

}
